home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / info-service / archie / clients / archie.el < prev    next >
Encoding:
Text File  |  1992-01-12  |  2.3 KB  |  72 lines

  1. ;;
  2. ;; archie.el v1.0 -- by Brendan Kehoe (brendan@cs.widener.edu)
  3. ;;
  4. ;; A mock-interface to Archie for Emacs.  This will shave by when you need
  5. ;; it.  ARCHIE-SEZ will insert the result of the query in the current buffer,
  6. ;; and plain ARCHIE will create a separate buffer .
  7. ;;
  8. ;; TODO: hack ange-ftp to use the output of archie -l, and let you select
  9. ;;       from a magic list which one you want to FTP into an Emacs buffer.
  10. ;;
  11.  
  12. (defvar archie-program "/usr/local/bin/archie"
  13.   "Program that queries archie servers.")
  14.  
  15. (defvar archie-server "archie.sura.net"
  16.   "Server for \\[archie] searches.
  17.  
  18. Known archie servers:
  19.     archie.ans.net (USA [NY])
  20.     archie.sura.net (USA [MD])
  21.     archie.mcgill.ca (Canada)
  22.     archie.funet.fi (Finland/Mainland Europe)
  23.     archie.au (Australia)
  24.     archie.doc.ic.ac.uk (Great Britain/Ireland)
  25. ")
  26.  
  27. (defvar archie-search-type "-e"
  28.   "Search type for \\[archie] searches.
  29. Can be one of: -c for substring searches
  30.                -e for exact matches (default)
  31.                -r for a regexp
  32.                -s for a case-insensitive substring search
  33. ")
  34.  
  35. (defun archie-sez (string)
  36.   "Insert the results of an archie query on STRING into the current buffer.
  37.    Uses the function `archie' for its main work."
  38.   (interactive (list (read-string "String: " nil)))
  39.   (archie string nil t))
  40.  
  41. (defun archie (string &optional type inplace)
  42.   "Look for STRING on an Archie server.
  43. Optional second arg TYPE is the type of search to make -- by default, it's
  44. `archie-search-type'.  Possible values are substring, subcase (case insensitive
  45. substring), and regexp (a regular expression).  Interactively, a prefix arg
  46. will make it prompt for this."
  47.   (interactive (list (read-string "String: " nil)
  48.              (and current-prefix-arg
  49.               (read-string "Search type [-c/-e/-r/-s]: "
  50.                        archie-search-type))))
  51.   (let ((buf (or inplace (get-buffer-create "*Archie*"))))
  52.     (if inplace
  53.     (progn
  54.       (push-mark (point) t)
  55.       (insert "Archie sez: \n"))
  56.       (progn
  57.     (pop-to-buffer buf)
  58.     (setq buffer-read-only nil
  59.           mode-line-process (concat ": " string)
  60.           mode-name "Query for"
  61.           minor-mode-alist nil)
  62.     (erase-buffer)))
  63.     (call-process archie-program nil buf nil
  64.           "-h" archie-server
  65.           (or type archie-search-type)
  66.           string))
  67.  
  68.   (if (not inplace)
  69.       (progn
  70.     (setq buffer-read-only t)
  71.     (goto-char (point-min)))))
  72.